

package com.hazelcast.map.impl;

import com.hazelcast.config.MapConfig;
import com.hazelcast.internal.services.ServiceNamespace;
import com.hazelcast.map.impl.recordstore.RecordStore;

import java.util.Collection;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Predicate;

public interface PartitionContainer {

    ConcurrentMap<String, RecordStore> getMaps();

    Collection<RecordStore> getAllRecordStores();

    Collection<ServiceNamespace> getAllNamespaces(int replicaIndex);

    Collection<ServiceNamespace> getNamespaces(Predicate<MapConfig> predicate, int replicaIndex);

    int getPartitionId();

    MapService getMapService();

    RecordStore getRecordStore(String name);

    RecordStore getRecordStore(String name, boolean skipLoadingOnCreate);

    RecordStore getRecordStoreForHotRestart(String name);

    RecordStore getExistingRecordStore(String mapName);

    void destroyMap(MapContainer mapContainer);

    boolean hasRunningCleanup();

    void setHasRunningCleanup(boolean hasRunningCleanup);

    long getLastCleanupTime();

    void setLastCleanupTime(long lastCleanupTime);

    long getLastCleanupTimeCopy();

    void setLastCleanupTimeCopy(long lastCleanupTimeCopy);

    /**
     * Cleans up the container's state if the enclosing partition is migrated
     * off this member. Whether cleanup is needed is decided based on the
     * provided {@code replicaIndex}.
     *
     * @param replicaIndex The replica index to use for deciding per map whether
     *                     cleanup is necessary or not
     */
    void cleanUpOnMigration(int replicaIndex);
}
